<?php
/*
	店长中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$_SESSION['forward_url']='jy_mzhaodian/index/';
	$return['setting']=$this->plugin_setting('page');
	set_html('title',$return['setting']['agent_center']?:'店长中心');
	$member=$this->model('zhaoshang')->checkmember('',true);
	if($member['status']!=1){
		$return['setting']['agent_title']=$return['setting']['agent_title']?:'商户店长';
		exi('','error','jy_mzhaodian/apply/');
	}
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	if($member['level_id']){
		$member['level']=pdo_getcolumn('jy_merch_level',array('id'=>$member['level_id']),'title');
	}else{
		$default_levelset=$this->plugin_setting('default_level');
		$member['level']=$default_levelset['title']?:'普通等级';
	}
	$return['ordernum']=pdo_count('jy_merch_commission',array('mid'=>$_SESSION['uid']));
	$return['member']=$member;
	$data=array();
	//已结算佣金
	$data['balance_total']=pdo_getsum('jy_merch_balance',array('mid'=>$_SESSION['uid']),'money');
	$data['balance_num']=pdo_count('jy_merch_balance',array('mid'=>$_SESSION['uid']));
	$data['merch_num']=pdo_count('jy_merch_user',array('zhaoshangid'=>$member['id']));
	//待结算佣金
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1);
	/*if($this->setting['balance_day']){
		//结算天数
		$time=TIMESTAMP-intval($this->setting['balance_day'])*86400;
		$params['complete_time <']=$time;
	}*/
	$data['commission_1']=pdo_getsum('jy_merch_commission',$params,'money');
	$data['commission_total']=pdo_getsum('jy_merch_commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'money');
	$return['data']=$data;
	exi($return);
}
?>